package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/dialect/entsql"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/field"
	"github.com/google/uuid"
)

// User holds the schema definition for the User entity.
type User struct {
	ent.Schema
}

// Fields of the User.
func (User) Fields() []ent.Field {
	return []ent.Field{
		field.UUID("id", uuid.UUID{}).Default(uuid.New).Unique().Immutable().Comment("主键"),
		field.String("account").NotEmpty().Unique().Immutable().Comment("账户号"),
		field.String("username").NotEmpty().Comment("用户名"),
		field.String("password").NotEmpty().Comment("密码"),
		field.String("nickname").NotEmpty().Comment("昵称"),
		field.Int32("age").Positive().Comment("年龄"),
		field.Enum("gender").Values("Male", "Female", "Neutral", "Unknown").Default("Unknown"), //https://entgo.io/docs/schema-fields#enum-fields
		field.String("remark").MaxLen(255).Default("").NotEmpty(),
		field.Bool("deleted").Default(false),
	}
}

func (User) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entsql.Annotation{Table: "users"},
	}
}
